package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Order;
import cn.wolfcode.trip.base.query.OrderQueryObject;
import cn.wolfcode.trip.base.service.IOrderService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("orders")
public class OrderController {

    @Autowired
    private IOrderService orderService;


    /**
     * 提交生成的订单
     * @param order
     * @return
     */
    @PostMapping("/commit")
    public Object saveOrder(Order order) {
        return  orderService.saveOrder(order);
    }

    /**
     * 获取用户所有的订单
     * @return
     */
    @GetMapping
    public Object getAllOrder(OrderQueryObject qo) {
        return  orderService.selectOrdersByUserId(qo);
    }



}
